package artibella.media.controls.views
{
	import artibella.media.controls.ui.FullScreenButton;
	import artibella.media.controls.ui.PlayPauseButton;
	import artibella.media.controls.ui.ProgressionTool;
	import artibella.media.controls.ui.StopButton;
	import artibella.media.controls.ui.TimeTool;
	import artibella.media.controls.ui.VolumeSlider;
	import artibella.media.controls.VideoController;
	import artibella.media.events.MediaEvent;
	import artibella.text.StylesManager;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author pbordachar
	 */
	
	public class RTB_VideoController extends VideoController
	{
		
		//private var _playlist:RTB_PlayList;
		
		public function RTB_VideoController() 
		{
			super();
		}
		
		// - - -
		
		override public function init():void
		{
			_drawBasicMediaControls();
		}
		
		private function _drawBasicMediaControls():void
		{
			setPlayBt( new PlayPauseButton( 0xFFFFFF ), 0, 0 );
			setStopBt( new StopButton( 0xFFFFFF ), 25, 0 );
			setProgressionTool( new ProgressionTool( this, 135, 0xFFFFFF ), 50, 0 );
			setTimeTool( new TimeTool( TimeTool.TIME, StylesManager.instance.getStyleFormat( ".player_time_tool2" ) ), 200, 0 );
			setVolumeTool( new VolumeSlider( this, 0xFFFFFF ), 255, 1 );
			setFullScreenBt( new FullScreenButton( 0xFFFFFF ), 280, 0 );
			
			_prog_tool.loadUpdate( 1 ); // pas de chargement !!!
		}
		
		// - - -
		
		override public function set labelText( s:String ):void
		{
			if ( _label != null ) _label.text = s.toUpperCase();
		}
		
		///////  M E D I A   E V E N T S
		
		override protected function _onPlay( e:MediaEvent ):void
		{
			_bt_play.drawPause();
			
			super._onPlay( e );
		}
		
		override protected function _onPause( e:MediaEvent ):void
		{
			_bt_play.drawPlay();
			
			super._onPause( e );
		}
		
		override protected function _onStop( e:MediaEvent ):void
		{
			_bt_play.drawPlay();
			
			super._onStop( e );
		}
		
		///////  P L A Y L I S T
		
		//override protected function _showList( e:MouseEvent ):void
		//{
			//if ( _playlist != null ) return;
			//
			//_bt_list.removeEventListener( MouseEvent.CLICK, _showList );
			//_bt_list.addEventListener( MouseEvent.CLICK, _hideList );
			//
			//_buildPlaylist();
		//}
		//
		//private function _buildPlaylist():void
		//{
			//if ( _player.list == null  ) return;
			//
			//_playlist = new RTB_PlayList( _player.list.items );
			//_playlist.addEventListener( MouseEvent.CLICK, _onListItemSelected );
			//_playlist.x = - 10;
			//_playlist.y = 60;
			//addChild( _playlist );
//
			//stage.dispatchEvent( new Event( Event.RESIZE ) );
		//}
		//
		//private function _onListItemSelected( e:MouseEvent ):void
		//{
			//_player.play( e.target.indice );
		//}
		//
		//override protected function _hideList( e:MouseEvent ):void
		//{
			//if ( _playlist == null ) return;
			//
			//_bt_list.removeEventListener( MouseEvent.CLICK, _hideList );
			//_bt_list.addEventListener( MouseEvent.CLICK, _showList );
			//
			//removeChild( _playlist );
			//
			//_playlist.removeEventListener( MouseEvent.CLICK, _onListItemSelected );
			//_playlist.dispose();
			//_playlist = null;
			//
			//stage.dispatchEvent( new Event( Event.RESIZE ) );
		//}
		
		// - - -
		
		override public function stageUpdate( w:int, h:int ):void
		{
			if ( _prog_tool != null ) _prog_tool.size = w - 185;
			if ( _time_tool != null ) _time_tool.x = w - 120;
			if ( _volume_tool != null ) _volume_tool.x = w - 65;
			if ( _bt_fullscreen != null ) _bt_fullscreen.x = w - 40;
			
			super.stageUpdate( w, h );
		}

		
	}
}